/**
 * Copyright (c) 2010-2011 julewa.com.  
 * All rights reserved. 
 * 
 * @author Huang Benhua
 * @date 2011-7-20
 * 
**/
package com.julewa.db.checkers;

import com.julewa.db.DataState;

public abstract class DataStateChecker {
	protected boolean primary;
	protected boolean nullable;
	protected double min;
	protected double max; 
	//protected String format;
	protected boolean checkMin;
	protected boolean checkMax;
	//protected boolean checkFormat;
	public void initialize(boolean primary, boolean nullable, 
			double min, double max){//, String format){
		this.primary = primary;
		this.nullable = nullable;
		this.min = min;
		this.max = max;
	//	this.format = format.trim();
		//
		this.checkMin = min != Double.MIN_VALUE;
		this.checkMax = max != Double.MAX_VALUE;
	//	this.checkFormat = this.format.length() > 0;
		//
		this._init();
	};
	//
	protected abstract void _init(); 
	protected abstract DataState _check(Object obj);
	public DataState check(Object obj){
		if(obj == null){
			if(nullable)return DataState.NORMAL;
			return DataState.IS_NULL;
		}
		return _check(obj);
	};

}
